<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      div {
        border: solid;
        padding: 10px;
      }
    </style>
  </head>
  <body>
    <div id="app"></div>
    <template id="t1">
      <div>
        <!-- 绑定捕获阶段事件处理函数 -->
        <div @click="hi(1)">
          box1
          <!-- 只有点击自身才能执行，不能冒泡执行（阻止冒泡执行） -->
          <div @click.self="hi(2)">
            box2
            <div @click="hi(3)">
              box3
              <!-- 处理函数只执行一次 -->
              <div @click.once="hi(4)">box4</div>
            </div>
          </div>
        </div>
      </div>
    </template>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        template: "#t1",
        data: {
          age: 10,
        },
        methods: {
          hi(e) {
            console.log(e);
          },
        },
      });
    </script>
  </body>
</html>
